<?php require VIEWPATH . ADMIN_DIR . DIRECTORY_SEPARATOR . 'header.php' ?>
<style type="text/css">
.dropdown-grade {
	margin-left: 10px;
}
.dropdown-grade li a{
	line-height: 24px;
}
#input-student {
	background-color: #FFF !important;
}
.div-submit {
	margin-top: 20px;
}
</style>
<div class="page-header">
	<h1>
		<a class="a-back" href="<?= admin_url('contents/exam_room_detail_data/' . $roomId) ?>">
            <i class="fa fa-reply"></i>
		</a>
		<?php if(isset($detailId)): ?>
			修改考场 编号<?= $detailId ?>
		<?php else: ?>
			添加考场
		<?php endif ?>

	</h1>
</div>
<div class="col-xs-12">
	<form id="exam-room-detail-form" class="form-horizontal">
		<!-- 考试id -->
		<input type="hidden" name="room_id" value="<?= $roomId ?>" />
		<!-- 考场id -->
        <input type="hidden" name="detail_id" value="<?= isset($detailId) ? $detailId : '' ?>" />
        <!-- 监考老师提交输入框 -->
		<input type="hidden" name="inside_teacher_ids" value='<?= isset($detail['inside_teachers']) ? $detail['inside_teachers'] : '' ?>' />
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">考场名称：</label>
            <div class="col-sm-6">
                <input class="form-control" type="text" name="room_name" value="<?= isset($detail['room_name']) ? $detail['room_name'] : '' ?>" placeholder="请填写考场名称" />
            </div>
        </div>
		<div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">考场位置：</label>
            <div class="col-sm-6">
				<select class="form-control" name="location_id">
					<?php foreach($classrooms as $classroom): ?>
                        <option value="<?= $classroom['id'] ?>"<?php if(isset($detail['location_id']) && $classroom['id'] == $detail['location_id']): ?>selected<?php endif ?>>
                            <?= $classroom['classroom_name'] ?>
                        </option>
					<?php endforeach ?> 
				</select>
            </div>
		</div>
		<div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">监考教师：</label>
			<span class="block input-icon input-icon-right pd0">
				<div class="col-sm-6">
					<span class="block input-icon input-icon-right pd0">
						<input class="width-100" type="text" placeholder="请选择教师" id="select-teacher" value="<?= isset($detail['teacherNames']) ? $detail['teacherNames'] : '' ?>" />
						<i class="ace-icon fa fa-user"></i>
					</span>
				</div>
            </span>
		</div>
		<div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">编号（第几考场）：</label>
            <div class="col-sm-6">
                <input class="form-control" type="number" name="room_no" value="<?= isset($detail['room_no']) ? $detail['room_no'] : 1 ?>" placeholder="请填写编号" />
            </div>
        </div>
        <div class="clearfix div-submit">
            <div class="col-md-offset-3 col-md-9">
                <button class="btn btn-info" type="submit">
                    <i class="ace-icon fa fa-check"></i> 提交
                </button>
            </div>
        </div>
	</form>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
	var table = "";
	$(function(){
		// 初始化选择老师控件
		$("#select-teacher").selectTeacher({
			"multiSelect": true,
			"resultDom": $("[name=inside_teacher_ids]"),
		});
		// 提交表单
		var form = $("#exam-room-detail-form");
		var submitUrl = "<?=admin_url('contents/save_exam_room_detail_action')?>";
		form_submit(form, submitUrl, function(res) {
			tips_alert(res.msg, res.success, function(){
				if(res.success) {
					window.location.href = "<?=admin_url('contents/exam_room_detail_data/' . $roomId)?>";
				}
			});
		})
	})
</script>